{{- $inner := .Inner | .Page.RenderString -}}

{{- $iconMap := dict "note" "admonition-icon icon-note" -}}
{{- $iconMap  = dict "abstract" "admonition-icon icon-abstract" | merge $iconMap -}}
{{- $iconMap  = dict "info" "admonition-icon icon-info" | merge $iconMap -}}
{{- $iconMap  = dict "tip" "admonition-icon icon-tip" | merge $iconMap -}}
{{- $iconMap  = dict "success" "admonition-icon icon-success" | merge $iconMap -}}
{{- $iconMap  = dict "question" "admonition-icon icon-question" | merge $iconMap -}}
{{- $iconMap  = dict "warning" "admonition-icon icon-warning" | merge $iconMap -}}
{{- $iconMap  = dict "failure" "admonition-icon icon-failure" | merge $iconMap -}}
{{- $iconMap  = dict "danger" "admonition-icon icon-danger" | merge $iconMap -}}
{{- $iconMap  = dict "bug" "admonition-icon icon-bug" | merge $iconMap -}}
{{- $iconMap  = dict "example" "admonition-icon icon-example" | merge $iconMap -}}
{{- $iconMap  = dict "quote" "admonition-icon icon-quote" | merge $iconMap -}}
{{- $iconDetails := "admonition-icon admonition-icon-arrow-right" -}}

{{- if .IsNamedParams -}}
    {{- $type := .Get "type" | default "note" -}}
    <div class="details admonition {{ $type }}{{ if .Get `open` | ne false }} open{{ end }}">
        <div class="details-summary admonition-title {{ if not (.Get `title`) }}admonition-title-none{{ end }}">
            {{- with (.Get "title") -}}
            <i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . | default (T $type) }}<i class="details-icon  {{ $iconDetails }}"></i>
            {{- end -}}
        </div>
        <div class="details-content">
            <div class="admonition-content">
                {{- $inner -}}
            </div>
        </div>
    </div>
{{- else -}}
    {{- $type := .Get 0 | default "note" -}}
    <div class="details admonition {{ $type }}{{ if .Get 2 | ne false }} open{{ end }}">
        <div class="details-summary admonition-title" style="display: none">
            <i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}<i class="details-icon {{ $iconDetails }}"></i>
        </div>
        <div class="details-content">
            <div class="admonition-content">
                {{- $inner -}}
            </div>
        </div>
    </div>
{{- end -}}
